package com.zsrt.oa.vip.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.zsrt.oa.vip.dao.VipDao;
import com.zsrt.oa.vip.entity.VipEntity;
import com.zsrt.utils.DBUtils;

/**
 * 会员信息实现类
 * @author 罗智壕-13424431416
 *
 * 2017年6月11日
 */
public class VipDaoImpl implements VipDao {
	
	/**
	 * 查找全部会员
	 * @return
	 */
	@Override
	public List<VipEntity> queryAllMessage() throws SQLException{
		List<VipEntity> list = new ArrayList<VipEntity>();
		Connection con = DBUtils.getMessage();
		String sql = "select "
				+ " vip_id as vipId,"
				+ " vip_name as vipName,"
				+ " vip_money as vipMoney,"
				+ " vip_discount as vipDiscount "
				+ " from tkt_vip_t";
		PreparedStatement ps = con.prepareStatement(sql);
		ResultSet rs = ps.executeQuery();
		
		while(rs.next()){
			VipEntity entity = new VipEntity();
			entity.setVipId(rs.getInt("vipId"));
			entity.setVipName(rs.getString("vipName"));
			entity.setVipMoney(rs.getDouble("vipMoney"));
			entity.setVipDiscount(rs.getDouble("vipDiscount"));
			list.add(entity);
		}

		return list;
	}

}
